<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>全部垃圾分类</title>
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="background-color: transparent;">
<div class="container" >
    <div class="row clearfix">
        <div class="col-md-9 column">
            <div class="page-header">
                <h1><small>
                    全部垃圾分类
                </small></h1>
            </div>
        </div>
        <div class="row">

            <div class="col-md-4 column col-md-offset-1">

                <a class="btn btn-primary" href="${pageContext.request.contextPath}/detail/allDetail">显示全部垃圾</a>
            </div>
            <div class="col-md-3 column"></div>

            <div class="col-md-4 column">
                <%--查询--%>
            <form action="${pageContext.request.contextPath}/detail/queryDetails" method="post" style="float: left;" class="form-inline">
               <span style="color: red;font-weight: bold">${error}</span>
                <input type="text" name="getDetailByName" class="form-control" placeholder="请输入准确的垃圾名称"/>
                <input type="submit" value="查询" class="btn btn-primary"/>
            </form>
            </div>
        </div>
    </div>

<div class="row clearfix">
    <div class="col-md-11 col-md-offset-1 column">
        <table class="table table-hover table-striped">
            <thead>
            <tr>
                <th>垃圾编号</th>
                <th>垃圾名称</th>
                <th>垃圾类别</th>
<%--                <th>垃圾照片</th>--%>
                <th>垃圾详情</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
<%-- 从数据库查询--%>
            <c:forEach var="detail" items="${list}">
                <tr>
                    <td width="50px">${detail.d_id}</td>
                    <td width="150px">${detail.d_name}</td>
                    <td width="150px">${detail.c_id==1?"干垃圾" :(detail.c_id==2?"湿垃圾"
                     :(detail.c_id==3?"可回收垃圾" :(detail.c_id==4?"有害垃圾"
                      :(detail.c_id==5?"大件垃圾" :(detail.c_id==6?"装修垃圾"
                       :(detail.c_id==7?"电子废弃物" :" "))))))}</td>
<%--                    <td>${detail.d_pic}</td>--%>
                    <td width="450px">${detail.d_detail}</td>
                    <td width="200px">
                        <a class="btn btn-info" href="${pageContext.request.contextPath}/detail/toUpdate?id=${detail.d_id}">修改</a>
                        &nbsp; | &nbsp;
                        <a class="btn btn-danger"  href="javascript:void(0)" onclick="sc(${detail.d_id})">删除</a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
</div>


<script type="text/javascript">

    function sc(id) {
        if(window.confirm("确认删除吗")){
            document.location="${pageContext.request.contextPath}/detail/delDetail?d_id="+id
        }
    }
</script>
</body>
</html>
